package cn.gok.homework;

class Worker {
    private  String name;
    private String job;
    private int salary;

    @Override
    public String toString() {
        return "Worker{" +
                "name='" + name + '\'' +
                ", job='" + job + '\'' +
                ", salary=" + salary +
                '}';
    }

    public Worker(String name, String job, int salary) {
        this.name = name;
        this.job = job;
        this.salary = salary;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getJob() {
        return job;
    }
    public void setJob(String job) {
        this.job = job;
    }
    public int getSalary() {
        return salary;
    }
    public void setSalary(int salary) {
        this.salary = salary;
    }
    public int dojob(int moths){
        System.out.println(this.name+"工作了"+moths+"个月,获得了"+this.salary+"工资");
        return this.salary*moths;
    }

}
class SuperWorker extends Worker{
    private float bonus;

    @Override
    public String toString() {
        return "SuperWorker{" +
                "bonus=" + bonus +
                '}';
    }

    public SuperWorker(String name, String job, int salary, float bonus) {
        super(name, job, salary);
        this.bonus = bonus;
    }

    public float getBonus() {
        return bonus;
    }

    public void setBonus(float bonus) {
        this.bonus = bonus;
    }

    public SuperWorker(String name, String job, int salary) {
        super(name, job, salary);
    }

    @Override
    public int dojob(int moths) {
        int a=(int) (this.getSalary()*moths*(1+bonus));
        return a;
    }
    public int dojob(int moths,int addtionalHours){
        return (int)(this.getSalary()*moths*(1+bonus)+this.bonus*getSalary()*addtionalHours/100);
    }
}
public class 作业 {
    public static void main(String[] args) {
        Worker worker = new Worker("南宫钓鱼", "农民", 4000);
        System.out.println("总工资" + worker.dojob(8));
        SuperWorker worker1 = new SuperWorker("欧阳铁柱", "渔民", 4000, (float) 0.5);
        System.out.println("总工资" + worker1.dojob(20));
        System.out.println(worker1.dojob(8, 5000));
    }

}